package interview6;

/**
 * @author Jack
 * @date 2019-11-02-15:32
 * 利用递归从尾到头打印链表
 */
public class Solution2 {

    public static void main(String[] args) {
        Node head = new Node(0);
        Node temp = head;
        for (int i = 1; i < 10; i++) {

            Node node = new Node(i);
            temp.setNext(node);
            temp = temp.getNext();

        }

        inverseLinkedList(head);
    }

    public static void inverseLinkedList(Node head){
        if(head == null){
            return ;
        }
        inverseLinkedList(head.getNext());
        System.out.print(head.getValue()+" ");
    }

}